<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.wqr.pojo.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta charset="utf-8">
  <!-- Title and other stuffs -->
  <title>登陆信息管理</title> 
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="author" content="">
  <!-- Stylesheets -->
  <link href="${pageContext.request.contextPath}/style/bootstrap.css" rel="stylesheet">
  <!-- Font awesome icon -->
  <link rel="stylesheet" href="${pageContext.request.contextPath}/style/font-awesome.css"> 
  <!-- jQuery UI -->
  <link rel="stylesheet" href="${pageContext.request.contextPath}/style/jquery-ui.css"> 
  <!-- Calendar -->
  <link rel="stylesheet" href="${pageContext.request.contextPath}/style/fullcalendar.css">
  <!-- prettyPhoto -->
  <link rel="stylesheet" href="${pageContext.request.contextPath}/style/prettyPhoto.css">  
  <!-- Star rating -->
  <link rel="stylesheet" href="${pageContext.request.contextPath}/style/rateit.css">
  <!-- Date picker -->
  <link rel="stylesheet" href="${pageContext.request.contextPath}/style/bootstrap-datetimepicker.min.css">
  <!-- CLEditor -->
  <link rel="stylesheet" href="${pageContext.request.contextPath}/style/jquery.cleditor.css"> 
  <!-- Uniform -->
  <link rel="stylesheet" href="${pageContext.request.contextPath}/style/uniform.default.css"> 
  <!-- Bootstrap toggle -->
  <link rel="stylesheet" href="${pageContext.request.contextPath}/style/bootstrap-switch.css">
  <!-- Main stylesheet -->
  <link href="${pageContext.request.contextPath}/style/style.css" rel="stylesheet">
  <!-- Widgets stylesheet -->
  <link href="${pageContext.request.contextPath}/style/widgets.css" rel="stylesheet">   
  
  <!-- HTML5 Support for IE -->
  <!--[if lt IE 9]>
  <script src="js/html5shim.js"></script>
  <![endif]-->

  <!-- Favicon -->
  <link rel="shortcut icon" href="img/favicon/favicon.png">
</head>

<body>

<%@ include file="../jsp/header.jsp" %>
<!-- Main content starts -->

<div class="content">

<%@ include file="../jsp/adminSidebar.jsp" %>

  	  <!-- Main bar -->
  	<div class="mainbar">
      
	    <!-- Page heading -->
	    <div class="page-head">
	      <h2 class="pull-left"><i class="icon-home"></i> 登陆信息管理</h2>

        <!-- Breadcrumb -->
        <div class="bread-crumb pull-right">
          <a href="${pageContext.request.contextPath}/adminMain.action"><i class="icon-home"></i> 首页</a> 
          <!-- Divider -->
          <span class="divider">/</span> 
          <a href="#" class="bread-current">控制台</a>
        </div>
        <div class="clearfix"></div>
	    </div>
	    <!-- Page heading ends -->
	    <!-- Matter -->
	    <div class="matter">
        <div class="container">
          <div class="row">
			<!-- Form starts.  -->
              <div class="form-horizontal" role="form"  id="frmLogin">
              <%-- action="${pageContext.request.contextPath}/addLogins.action" method="post" onsubmit="return checkInput()" --%>
              <input type="hidden" id="hidLoginId" name="hidLoginId"/><!-- 带参数，传参数（隐藏的） -->
              <input type="hidden" id="hidCurrentPageIndex" name="hidCurrentPageIndex" 
                value="${currentPageIndex}"/>
              <input type="hidden" id="hidPageSize" name="hidPageSize" value="${pageSize}"/>
              <input type="hidden" id="hidSortField" name="hidSortField" value="${sortField }"/>	
           	  <input type="hidden" id="hidSortString" name="hidSortString" value="${sortString }"/>
            <div class="col-md-12">

              <div class="widget wgreen">
                
                <div class="widget-head">
                  <div class="pull-left">登陆信息填写</div>
                  <div class="widget-icons pull-right">
                    <a href="#" class="wminimize"><i class="icon-chevron-down"></i></a> 
                    <a href="#" class="wclose"><i class="icon-remove"></i></a>
                  </div>
                  <div class="clearfix"></div>
                </div>

                <div class="widget-content" style="display:none" id="modify">
                  <div class="padd">
                    <div class="form-group">
                      <label class="col-lg-4 control-label">登陆名称</label>
                      <div class="col-lg-8">
                        <input type="text" class="form-control" id="txtLoginName" name="txtLoginName"  placeholder="登陆名称" value="">
                        <span class="label label-danger" id="spanLoginName"></span>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-lg-4 control-label">Email</label>
                      <div class="col-lg-8">
                        <input type="text" class="form-control" id="txtEmail" name="txtEmail"  placeholder="Email" value="">
                        <span class="label label-danger" id="spanEmail"></span>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-lg-4 control-label">登陆类型</label>
                      <div class="col-lg-8">
                        <select class="form-control" id="txtStateId" name="txtStateId" >
						</select>
                      </div>
                    </div> 
                    <div class="form-group">
                      <label class="col-lg-4 control-label">登陆状态</label>
                      <div class="col-lg-8">
                        <select class="form-control" id="txtTypeId" name="txtTypeId" >
						</select>
                      </div>
                    </div> 
                    <div class="form-group">
                      <label class="col-lg-4 control-label">备注</label>
                      <div class="col-lg-8">
                        <textarea rows="3" class="form-control" id="txtRemark" name="txtRemark" placeholder="备注"></textarea>
                        <span class="label label-danger" id="spanRemark"></span>
                    	</div>
                    </div>    
                    <hr />
                    <div class="form-group">
                      <div class="col-lg-offset-1 col-lg-9">
                      	<div id ="Modify1" >
                        <button onclick="addLogin()" class="btn btn-primary">添加</button>                             
                        <button type="reset" class="btn btn-default">取消</button>
                       </div> 
                       <div id="Modify2" style="display:none" >
                        <button onclick="saveLogin()" class="btn btn-primary">保存</button>                             
                        <button class="btn btn-default" onclick="cancelSaveLogin()" >取消</button>
                       </div>
                       </div>
                   </div>
	             </div>
	           </div>
	             <div class="widget-foot">
	               <!-- Footer goes here -->
	             </div>
	         </div>  
			<div class="widget wgreen">
                <div class="widget-head">
                  <div class="pull-left">查询登陆信息</div>
                  <div class="widget-icons pull-right">
                    <a href="#" class="wminimize"><i class="icon-chevron-down"></i></a> 
                    <a href="#" class="wclose"><i class="icon-remove"></i></a>
                  </div>
                  <div class="clearfix"></div>
                </div>

                <div class="widget-content" style="display:none" id="search">
                  <div class="padd">
                    <div class="form-group">
                      <label class="col-lg-4 control-label">登陆名称</label>
                      <div class="col-lg-8">
                        <input type="text" class="form-control" id="txtSearchLoginName" name="txtSearchLoginName" 
                        placeholder="登陆名称"value="">
                        <span class="label label-danger" id="spanSearchLoginName"></span>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-lg-4 control-label">Email</label>
                      <div class="col-lg-8">
                        <input type="text" class="form-control" id="txtSearchEmail" name="txtSearchEmail" 
                        placeholder="Email"value="">
                        <span class="label label-danger" id="spanSearchEmail"></span>
                      </div>
                    </div>
                     <div class="form-group">
                      <label class="col-lg-4 control-label">注册时间</label>
                      <div class="col-lg-3">
                        <input type="text" class="form-control" id="txtSearchRegisterBegin" name="txtSearchRegisterBegin" 
                          placeholder="开始时间" value="2000-01-01 00:00:00.0" 
                          onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})">
                      </div>
                      <div class="col-lg-3">
                        <input type="text" class="form-control" id="txtSearchRegisterEnd" name="txtSearchRegisterEnd" 
                          placeholder="结束时间" value="2050-01-01 00:00:00.0" 
                          onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})">
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-lg-4 control-label">登陆类型</label>
                      <div class="col-lg-8">
                        <select class="form-control" id="txtSearchStateId" name="txtSearchStateId" >
						</select>
                      </div>
                    </div> 
                    <div class="form-group">
                      <label class="col-lg-4 control-label">登陆状态</label>
                      <div class="col-lg-8">
                        <select class="form-control" id="txtSearchTypeId" name="txtSearchTypeId" >
						</select>
                      </div>
                    </div> 
                    <div class="form-group">
                      <div class="col-lg-offset-1 col-lg-9">
                        <button class="btn btn-primary" onclick="searchLogin()">查询</button>                             
                        <button type="reset" class="btn btn-default" onclick="cancelSearchLogin()">取消查询</button>
                       </div>
                   </div>
	             </div>
	           </div>
	             <div class="widget-foot">
	               <!-- Footer goes here -->
	             </div>
	         </div>
	       </div>
		</div>
	   </div>


       <!-- Table -->
         <div class="row">
           <div class="col-md-12">
             <div class="widget">
             <div class="widget-head">
               <div class="pull-left">登陆信息表</div>
               <div class="widget-icons pull-right">
                 <a href="#" class="wminimize"><i class="icon-chevron-up"></i></a> 
                 <a href="#" class="wclose"><i class="icon-remove"></i></a>
               </div>
              
               <div class="clearfix"></div>
             </div>

               <div class="widget-content">

                 <table class="table table-striped table-bordered table-hover">
                   <thead>
                     <tr>
                       <th><a href="javascript: sorting('loginId')">序号</a></th>	<%--排序字段 --%>
                       <th><a href="javascript: sorting('loginName')">登陆名称</a></th>
                       <th><a href="javascript: sorting('email')">Email</a></th>
                       <th><a href="javascript: sorting('registerTime')">注册时间</a></th>
                       <th><a href="javascript: sorting('userStateId')">登陆状态</a></th>
                       <th><a href="javascript: sorting('userTypeId')">登陆类型</a></th>
                       <th><a href="javascript: sorting('remark')">备注</a></th>
                       <th>操作</th>                          
                     </tr>
                   </thead>
                   <tbody id="myTable">
                    <%--  <c:forEach items="${loginNameList }" var="loginState" 
                     begin="${(currentPageIndex - 1) * pageSize }" end="${currentPageIndex * pageSize - 1 }"> --%>
	                  	<c:forEach items="${itemList }" var="loginList" varStatus="status">
	                    <tr>
	                      <td>${loginList.loginId} </td>
	                      <td>${loginList.loginName}</td>
	                      <td>${loginList.email}</td>
	                      <td><fmt:formatDate value="${loginList.registerTime}" pattern="yyyy.MM.dd HH:mm:ss"/></td>
	                      <td>${loginList.userStateName}</td>
	                      <td>${loginList.userTypeName}</td>
	                      <td>${loginList.remark}</td>
	                      <td>
	                          <button class="btn btn-xs btn-warning" onclick="modifyLogin(${loginList.loginId})" > 
	                          <i class="icon-pencil"></i> </button>
	                          <button class="btn btn-xs btn-danger" onclick="removeLogin(${loginList.loginId})">
	                          <i class="icon-remove"></i> </button> 
	                      </td>
	                    </tr>    
	                    </c:forEach>   
                   </tbody>
                   <tbody id="tbody-result"></tbody>
                 </table>
				 
                 <div class="widget-foot">  
                    共${rowCount}条数据&nbsp;&nbsp;&nbsp;第${currentPageIndex}/${pageCount}页 &nbsp;&nbsp;&nbsp;
		               <label>
		                 <input type="radio" name="radPageSize"  value="20" onclick="resize(this.value)" <c:if test="${pageSize == 20}">checked</c:if>>20条/页
		               </label>&nbsp;&nbsp;
		               <label>
		                 <input type="radio" name="radPageSize" value="30" onclick="resize(this.value)" <c:if test="${pageSize == 30}">checked</c:if>>30条/页
		               </label>&nbsp;&nbsp;
		               <label>
		                 <input type="radio" name="radPageSize" value="50" onclick="resize(this.value)" <c:if test="${pageSize == 50}">checked</c:if>>50条/页
		               </label>
                     <ul class="pagination pull-right">
                     
                     <c:if test="${currentPageIndex <= 1 }">
                          <li><a href="#">首页</a></li>
                          <li><a href="#">上一页</a></li>
                        </c:if>
                        <c:if test="${currentPageIndex > 1 }">
                          <li><a href="javascript: paging(1)">首页</a></li>
                          <li><a href="javascript: paging(${currentPageIndex - 1 })">上一页</a></li>
                        </c:if>
                        <c:if test="${currentPageIndex >= pageCount }">
                          <li><a>下一页</a></li>
                          <li><a>尾页</a></li>
                        </c:if>  
                        <c:if test="${currentPageIndex < pageCount }">
                          <li><a href="javascript: paging(${currentPageIndex + 1 })">下一页</a></li>
                          <li><a href="javascript: paging(${pageCount })">尾页</a></li>
                        </c:if>
                     </ul>                    
                   <div class="clearfix"></div> 
                 </div>
               </div>
             </div>
           </div>
         </div>
 
		<!-- Matter ends -->

    </div>
 </div>
 </div>

   <!-- Mainbar ends -->
   <div class="clearfix"></div>

</div>
<!-- Content ends -->

<%@include file="../jsp/admin_footer.jsp" %>


<!-- Scroll to top -->
<span class="totop"><a href="#"><i class="icon-chevron-up"></i></a></span> 

<!-- JS -->
<script src="${pageContext.request.contextPath}/js/jquery.js"></script> <!-- jQuery -->
<script src="${pageContext.request.contextPath}/js/bootstrap.js"></script> <!-- Bootstrap -->
<script src="${pageContext.request.contextPath}/js/jquery-ui-1.9.2.custom.min.js"></script> <!-- jQuery UI -->
<script src="${pageContext.request.contextPath}/js/fullcalendar.min.js"></script> <!-- Full Google Calendar - Calendar -->
<script src="${pageContext.request.contextPath}/js/jquery.rateit.min.js"></script> <!-- RateIt - Star rating -->
<script src="${pageContext.request.contextPath}/js/jquery.prettyPhoto.js"></script> <!-- prettyPhoto -->

<!-- jQuery Flot -->
<script src="${pageContext.request.contextPath}/js/excanvas.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.flot.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.flot.resize.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.flot.pie.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.flot.stack.js"></script>

<!-- jQuery Notification - Noty -->
<script src="${pageContext.request.contextPath}/js/jquery.noty.js"></script> <!-- jQuery Notify -->
<script src="${pageContext.request.contextPath}/js/themes/default.js"></script> <!-- jQuery Notify -->
<script src="${pageContext.request.contextPath}/js/layouts/bottom.js"></script> <!-- jQuery Notify -->
<script src="${pageContext.request.contextPath}/js/layouts/topRight.js"></script> <!-- jQuery Notify -->
<script src="${pageContext.request.contextPath}/js/layouts/top.js"></script> <!-- jQuery Notify -->
<!-- jQuery Notification ends -->

<script src="${pageContext.request.contextPath}/js/sparklines.js"></script> <!-- Sparklines -->
<script src="${pageContext.request.contextPath}/js/jquery.cleditor.min.js"></script> <!-- CLEditor -->
<script src="${pageContext.request.contextPath}/js/bootstrap-datetimepicker.min.js"></script> <!-- Date picker -->
<script src="${pageContext.request.contextPath}/js/jquery.uniform.min.js"></script> <!-- jQuery Uniform -->
<script src="${pageContext.request.contextPath}/js/bootstrap-switch.min.js"></script> <!-- Bootstrap Toggle -->
<script src="${pageContext.request.contextPath}/js/filter.js"></script> <!-- Filter for support page -->
<script src="${pageContext.request.contextPath}/js/custom.js"></script> <!-- Custom codes -->
<script src="${pageContext.request.contextPath}/js/charts.js"></script> <!-- Charts & Graphs -->

<!-- Script for this page -->
<script type="text/javascript">
$(function () {
	getService();
	getSearchService();
    /* Bar Chart starts */

    var d1 = [];
    for (var i = 0; i <= 20; i += 1)
        d1.push([i, parseInt(Math.random() * 30)]);

    var d2 = [];
    for (var i = 0; i <= 20; i += 1)
        d2.push([i, parseInt(Math.random() * 30)]);


    var stack = 0, bars = true, lines = false, steps = false;
    
    function plotWithOptions() {
        $.plot($("#bar-chart"), [ d1, d2 ], {
            series: {
                stack: stack,
                lines: { show: lines, fill: true, steps: steps },
                bars: { show: bars, barWidth: 0.8 }
            },
            grid: {
                borderWidth: 0, hoverable: true, color: "#777"
            },
            colors: ["#ff6c24", "#ff2424"],
            bars: {
                  show: true,
                  lineWidth: 0,
                  fill: true,
                  fillColor: { colors: [ { opacity: 0.9 }, { opacity: 0.8 } ] }
            }
        });
    }
    //plotWithOptions();
    
    $(".stackControls input").click(function (e) {
        e.preventDefault();
        stack = $(this).val() == "With stacking" ? true : null;
        plotWithOptions();
    });
    $(".graphControls input").click(function (e) {
        e.preventDefault();
        bars = $(this).val().indexOf("Bars") != -1;
        lines = $(this).val().indexOf("Lines") != -1;
        steps = $(this).val().indexOf("steps") != -1;
        plotWithOptions();
    });

    /* Bar chart ends */

});


/* Curve chart starts */

$(function () {

	//jq 选中resize中值为pageSize的选项
	$("#resize option[value='${pageSize}']").attr('selected', true);
    var sin = [], cos = [];
    for (var i = 0; i < 14; i += 0.5) {
        sin.push([i, Math.sin(i)]);
        cos.push([i, Math.cos(i)]);
    }

    var plot = $.plot($("#curve-chart"),
           [ { data: sin, label: "sin(x)"}, { data: cos, label: "cos(x)" } ], {
               series: {
                   lines: { show: true, fill: true},
                   points: { show: true }
               },
               grid: { hoverable: true, clickable: true, borderWidth:0 },
               yaxis: { min: -1.2, max: 1.2 },
               colors: ["#1eafed", "#1eafed"]
             });

    function showTooltip(x, y, contents) {
        $('<div id="tooltip">' + contents + '</div>').css( {
            position: 'absolute',
            display: 'none',
            top: y + 5,
            left: x + 5,
            border: '1px solid #000',
            padding: '2px 8px',
            color: '#ccc',
            'background-color': '#000',
            opacity: 0.9
        }).appendTo("body").fadeIn(200);
    }

    var previousPoint = null;
    $("#curve-chart").bind("plothover", function (event, pos, item) {
        $("#x").text(pos.x.toFixed(2));
        $("#y").text(pos.y.toFixed(2));

        if ($("#enableTooltip:checked").length > 0) {
            if (item) {
                if (previousPoint != item.dataIndex) {
                    previousPoint = item.dataIndex;
                    
                    $("#tooltip").remove();
                    var x = item.datapoint[0].toFixed(2),
                        y = item.datapoint[1].toFixed(2);
                    
                    showTooltip(item.pageX, item.pageY, 
                                item.series.label + " of " + x + " = " + y);
                }
            }
            else {
                $("#tooltip").remove();
                previousPoint = null;            
            }
        }
    }); 

    $("#curve-chart").bind("plotclick", function (event, pos, item) {
        if (item) {
            $("#clickdata").text("You clicked point " + item.dataIndex + " in " + item.series.label + ".");
            plot.highlight(item.series, item.datapoint);
        }
    });

});
function checkInput(){
	var txtLoginName = document.getElementById("txtLoginName");
	var spanLoginName = document.getElementById("spanLoginName");
	
	if(txtLoginName.value.length == 0){
		spanLoginName.innerHTML = "登陆名称不能为空。";
		return false;
	}
	else{
		spanLoginName.innerHTML="";
		return true;
	}
}
function checkSearch(){
	var txtSearchLoginName = $("#txtSearchLoginName").val();
	var txtSearchDescription = $("#txtSearchDescription").val();
	var spanSearch = $("#spanSearch").val();
	
	if(txtSearchLoginName.length == 0
		&&txtSearchDescription.length == 0) {
		spanSearch.innerHTML = "登陆名称不能为空。";
		return false;
	}
	
	return true;
}
function addLogin(){
	var loginName = $("#txtLoginName").val();
	var stateId = $('#txtStateId option:selected').val();
	var typeId = $('#txtTypeId option:selected').val();
	var email = $("#txtEmail").val();
	var remark = $("#txtRemark").val();
	
	var login_json = {  
	           "loginName":loginName,
	           "email":email,
	           "userStateId":stateId,
	           "userTypeId":typeId,
	           "remark":remark
	           }      
		//js对象转换成JSON字符串  
	   var jason_str = JSON.stringify(login_json);  
		if(checkInput()) {
		    $.ajax({  
		        url :"${pageContext.request.contextPath }/addLogin.action",   
		        cache : true,  
		        type : "post",  
		        datatype : "json",  
		        contentType : "application/json; charset=utf-8",  
		        data : jason_str,  
		        success : function(data){  
		            //返回空值  
		            if(data == 0){  
		                alert("添加出现未知错误！");  
		                //alert(data);
		                //window.location.href = "sighIn.html";  
		            } else{   
		            	alert("添加成功！");
		            	//window.location.reload();
		                }  
		            window.location.reload();
		            }  
		    });
		}
}

function removeLogin(loginId){
	var login_json = {  
            "loginId":loginId
            }      
	//js对象转换成JSON字符串  
    var jason_str = JSON.stringify(login_json);  
	if(confirm("确定要删除么？")){
		//Ajax发送数据给后台  
        $.ajax({  
            url :"${pageContext.request.contextPath }/deleteLogin.action",   
            cache : true,  
            type : "post",  
            datatype : "json",  
            contentType : "application/json; charset=utf-8",  
            data : jason_str,  
            success : function (data){  
             	//返回空值  
                if(data == 0){  
                    alert("删除出现未知错误！");  
                } else{  //存在该登陆  
                	alert("删除成功！");
                    }
                window.location.reload();
                }
        	
        });  
	}
}

function modifyLogin(loginId){
	var login_json = {  
            "loginId":loginId
            }   
	//js对象转换成JSON字符串  
    var jason_str = JSON.stringify(login_json);  
	//Ajax发送数据给后台  
    $.ajax({  
        url :"${pageContext.request.contextPath }/updateLogin.action",   
        cache : true,  
        type : "post",  
        datatype : "json",  
        contentType : "application/json; charset=utf-8",  
        data : jason_str,  
        success : function (data){  
         	//返回空值  
         	if(data != null){
         		$("#modify").css('display','block'); 
         		$("#Modify1").css('display','none');
         		$("#Modify2").css('display','block');
         		
         		$("#hidLoginId").val("");
         		$("#txtLoginName").val("");
         		$('#txtSearchEmail').val("");
         		$("#txtSearchStateId").val("");
         		$("#txtSearchTypeId").val("");
         		$('#txtRemark').val("");
         		
         		$("#hidLoginId").val(data.loginId);
         		$("#txtLoginName").val(data.loginName);
         		$("#txtEmail").val(data.email);
         		$("#txtStateId").val(data.userStateId);
         		$("#txtTypeId").val(data.userTypeId);
         		$("#txtRemark").val(data.remark);
         	}
         }
    });  
}

function cancelSaveLogin(){
	$("#modify").css('display','none'); 
	$("#Modify1").css('display','block');
	$("#Modify2").css('display','none');
	$("#hidLoginId").val("");
	$("#txtLoginName").val("");
	$('#txtSearchEmail').val("");
	$("#txtSearchStateId").val("");
	$("#txtSearchTypeId").val("");
	$('#txtRemark').val("");
}

function saveLogin() {
	var loginId = $("#hidLoginId").val();
	var loginName = $("#txtLoginName").val();
	var userStateId = $('#txtStateId option:selected').val();
	var userTypeId = $('#txtTypeId option:selected').val();
	var email = $("#txtEmail").val();
	var remark = $("#txtRemark").val();
	var login_json = {
		   "loginId":loginId,
           "loginName":loginName,
           "userStateId":userStateId,
           "userTypeId":userTypeId,
           "email":email,
           "remark":remark
           }      
		//js对象转换成JSON字符串  
	   var jason_str = JSON.stringify(login_json);  
		if(checkInput()) {
		    $.ajax({  
		        url :"${pageContext.request.contextPath }/saveLogin.action",   
		        cache : true,  
		        type : "post",  
		        datatype : "json",  
		        contentType : "application/json; charset=utf-8",  
		        data : jason_str,  
		        success : function(data){  
		            //返回空值  
		            if(data == 0){  
		                alert("修改出现未知错误！");  
		                //window.location.href = "sighIn.html";  
		            } else{   
		            	alert("修改成功！");
		                }  
		            window.location.reload();
		            }  
		    });
		}
}

function getLocalTime(nS) {     
	   return new Date(parseInt(nS)).toLocaleString().replace(/:\d{1,2}$/,' ');     
	}
function searchLogin() {
if (checkSearch()) {
	var loginName = $("#txtSearchLoginName").val();
	var email = $("#txtSearchEmail").val();
	var registerBegin = $("#txtSearchRegisterBegin").val();
	var registerEnd = $("#txtSearchRegisterEnd").val();
	var stateId = $('#txtSearchStateId option:selected').val();
	var typeId = $('#txtSearchTypeId option:selected').val();
	$("#myTable").hide();
	var str = null;
	var login_json = {  
            "loginName":loginName,
            "email":email,
            "registerBegin":registerBegin,
            "registerEnd":registerEnd,
            "stateId":stateId,
            "typeId":typeId
            }   
	//js对象转换成JSON字符串  
	var jason_str = JSON.stringify(login_json);
    $.ajax({  
        url :"${pageContext.request.contextPath }/searchLogin.action",   
        cache : true,  
        type : "post",  
        datatype : "json",  
        contentType : "application/json; charset=utf-8",  
        data : jason_str,  
        success : function(data){ 
           if(data.length>0){
        	   for (i in data) { 
        		  str += "<tr>" +
        		  "<td>" + data[i].loginId + "</td>" +
        		  "<td>" + data[i].loginName + "</td>" +
        		  "<td>" + data[i].email + "</td>" +
                  "<td>" + getLocalTime(data[i].registerTime) + "</td>" +
                  "<td>" + data[i].userStateName + "</td>" +
                  "<td>" + data[i].userTypeName + "</td>" +
                  "<td>" + data[i].remark + "</td>" +
                  "<td>" +
                  "<button class='btn btn-xs btn-warning' onclick='modifyLogin( " +
                    		  data[i].loginId +
                    		  " )' > " +
                      "<i class='icon-pencil'></i> </button>" +
                      "<button class='btn btn-xs btn-danger' onclick='removeLogin( " +
                    		  data[i].loginId +
                    		  " )'> " +
                      "<i class='icon-remove'></i> </button> " +
                 "</td>" +
                "</tr>"     
        	   }
        	  $("#tbody-result").prepend(str);
           }
           else{
        	   alert("无符合条件的结果");
           }
    		}
   		});
    }
}
function cancelSearchLogin() {
	$("#myTable").show();
	$("#tbody-result").hide();
	$("#search").css('display','none');
	
	$("#txtSearchLoginName").val("");
	$('#txtSearchGender option:selected').val("");
	$("#txtSearchPhoneNumber").val("");
	$('#txtSearchRemark').val("");
}
function getService() {
	var str = null;
	$("select[name=txtTypeId]").empty();      //清空  
  $.ajax({  
      url :"${pageContext.request.contextPath }/searchAllUserTypes.action",   
      cache : true,  
      type : "post",  
      datatype : "json",  
      contentType : "application/json; charset=utf-8",  
      data : "",  
      success : function(data){
    	  for (var i in data) {  
              str += "<option value='"+ data[i].userTypeId + "'>" +data[i].userTypeName+"</option>";
          } 
    	  $("#txtTypeId").prepend(str);
    	  $("#txtSearchTypeId").prepend(str);
      },  
      error: function (msg) {  
          alert("出错了！");  
      }  
  });
}
function getSearchService() {
	var str = "";
	$("select[name=txtSearchStateId]").empty();      //清空  
  $.ajax({  
      url :"${pageContext.request.contextPath }/searchAllUserStates.action",   
      cache : true,  
      type : "post",  
      datatype : "json",  
      contentType : "application/json; charset=utf-8",  
      data : "",  
      success : function(data){
    	      	  for (var i in data) {
              str += "<option value='"+ data[i].userStateId + "'>" +data[i].userStateName+"</option>";
          } 
    	  $("#txtSearchStateId").prepend(str);
    	  $("#txtStateId").prepend(str);
      },  
      error: function (msg) {  
          alert("出错了！");  
      }  
  });
}

</script>

</body>
</html>